<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title></title>
    <c:import url="../../header.jsp"/>
</head>
<body>
<div class="content-warp">
    <div class="dgg-list-top-warp">
        <form action="" id="searchForm">
            <div class="screen-search">
            <ul>
                <li>
                    <label>客户号码：</label>
                    <input type="text" class="dggui-input dggui-input-normal" name="customerPhone" placeholder="输入电话号码">
                </li>
                <li>
                    <label>所属生产事业部：</label>
                    <select id="productOrgId" name="productOrgId" >
                    </select>
                </li>
                <li>
                    <label>订单状态：</label>
                    <select name="orderStatus" id="orderStatus" style="min-width: 80px; display: none;">
                    </select>
                </li>
                <li>
                    <label>业务类型：</label>
                    <div name="typeCode" id="typeCode"></div>
                </li>
                <li>
                    <label>产品：</label>
                    <select name="productCode" id="productCode" style="min-width: 80px; display: none;">
                    </select>
                </li>
                <li>
                    <label>流程人员：</label>
                    <select id="flowUserId" name="flowUserId"  style="min-width: 80px; display: none;">
                    </select>
                </li>
                <li>
                    <label>签单商务：</label>
                    <select  id="signUserId" name="signUserId">
                    </select>
                </li>
                <li>
                    <label>超期状态：</label>
                    <select  id="SQSTATUS" name="SQSTATUS">
                        <option value="">全部</option>
                        <option value="OUT_TIME_STATE5">未超期</option>
                        <option value="OUT_TIME_STATE2">分配超期</option>
                        <option value="OUT_TIME_STATE1">接收超期</option>
                        <option value="OUT_TIME_STATE3">节点超期</option>
                        <option value="OUT_TIME_STATE4">订单超期</option>
                    </select>
                </li>
                <li>
                    <label>签单时间：</label>
                    <input type="text" class="dggui-input" id="signTime" name="signTime">
                </li>
                <li>
                    <label>关键字：</label>
                    <input type="text" class="dggui-input dggui-input-large" name="keyword" placeholder="客户名/订单编号/生产订单编号" maxlength="50" style="width: 190px;">
                </li>
                <li>
                    <button class="dggui-btn searchBtn" onclick="search($('#test1'))">搜索</button>
                    <button class="dggui-btn dggui-btn-primary" onclick="cleanSearch()">清空条件</button>
                    <button class="dggui-btn dggui-btn-green">导出</button>
                </li>
            </ul>
        </div>
        </form>
    </div>
    <div class="list-content">
        <div class="tool-bar">
            <div class="fl">
                <a href="javascript:void(0)"class="dggui-btn dggui-btn-primary">打电话</a>
                <a href="javascript:void(0)"class="dggui-btn dggui-btn-primary">备注</a>
            </div>
        </div>
        <div class="table-warp">
            <table class="dggui-table" id="test1">
            </table>
        </div>
    </div>
</div>

<c:import url="/WEB-INF/jsp/footer.jsp"/>
<script>
    var NORMAL = '${NORMAL}', TIME_OUT = '${TIME_OUT}';
    dggui.use(['table', 'select2','distpicker','dggdate'], function (){
        var table = dggui.table;
        var select2 = dggui.select2;
        var distpicker=dggui.distpicker;
        var dggdate = dggui.dggdate;
        //初始化所属生产事业部
        syb("#productOrgId");
        select2.render({
            placeholder: "请选择",
            elem: $('#productOrgId'),
            allowClear: true,
            width: "190px"
        });
        //初始化订单状态
        commonTreeBookCode("#orderStatus", "RZSCORDER_STATUS", 1, 1, 1, true);
        select2.render({
            placeholder: "请选择",
            allowClear: true,
            elem: $('#orderStatus'),
            width: "190px"
        });
        select2.render({
            placeholder: "请选择",
            allowClear: true,
            elem: $('#productCode'),
            width: "190px"
        });
        //初始化业务类型及产品
        distpicker.render({
            url: "${basePath}/rzsc/common/tree_book_list.do?code=BUS_YT_DK&type=2&level=2", // 请求地址
            elem: '#typeCode', // 容器Id
            type: 2, // 1 省市区 2 业态
            placeholder: '选择业态',
            defaultParentCode:'BUS_YT',
            callback:function () {
                var code = $("#typeCode .plug-in-code").val();
                initProductCode("#productCode",code);
                select2.render({
                    placeholder: "请选择",
                    allowClear: true,
                    elem: $('#productCode'),
                    width: "190px"
                });
            },
            callbackClear:function () {
                $("#productCode").find("option").remove();
                $("#productCode").append("<option value=''>请选择</option>");
                $("#channelCode").find("option").remove();
                $("#channelCode").append("<option value=''>请选择</option>");
            }
        });
        //初始化流程人员
        initUser("RZSC_FLOW_USER","role","#flowUserId");
        select2.render({
            placeholder: "请选择",
            allowClear: true,
            elem: $('#flowUserId'),
            width: "190px"
        });
        //初始化签单商务
        initUser("bus_advisor","role","#signUserId");
        select2.render({
            placeholder: "请选择",
            allowClear: true,
            elem: $('#signUserId'),
            width: "190px"
        });
        //初始化签单时间
        dggdate.render({
            elem: '#signTime',
            type: 'date',
            range: '~'
        });

        var opt={
            "elem":"#test1",
            "ajax": sysInfo.basePath +"/demo/list.do",
            "scrollX": "true",//是否开启横项滚动
            "fixedColumns": {//锁定列，只有开启scrollX时才生效
                "leftColumns": 4,//左侧锁定2列
                "rightColumns": 1//右侧锁定1列
            },
            "fnServerParams": function (aoData) {
                //搜索条件
                //aoData = $.extend(aoData, $("#searchForm").serializeObject());
                aoData = $.extend(aoData, serializeObject($("#searchForm")));
                console.log(aoData)
                return aoData;
            },
            "aoColumns": [
                {
                "sClass": "check-th",
                "title": '<input type="checkbox" name="checklist" id="checkall">',
                "render": function(data, type, full, meta) {
                    return '<input type="checkbox" class="checkchild" name="checkchild" value="' + data + '">';
                    }
                },
                {
                    "title": "序号",
                    "render": function(data, type, full, meta) {
                        return meta.row + 1;
                    }
                },
                {
                    "title": "所属生产事业部",
                    "data": "signOrgName",
                    "orderable": false,
                    "render": function(data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "title": "订单编号",
                    "orderable": false,
                    "data": "orderNo",
                    "render": function (data, type, full, meta) {
                        return ('<a href=\'javascript:void(0)\' class="layui-table-link"  onclick="openBusinessDetail(\'' + full.orderNo + '\',\'' + full.orderId + '\')" /><span>' + data + '</span></a>');
                    }
                },
                {
                    "title": "生产订单编号",
                    "orderable": false,
                    "data": "scProductOrderNo",
                    "render": function (data, type, full, meta) {
                        var result = "";
                        result += '<a href="javascript:;"  class="layui-table-link" onclick="openOrderInfoDetail(\'' + full.scProductOrderNo + '\',\'' + full.id + '\')" /><span>' + data + '</span></a>';
                        return result;
                    }
                },
                {
                    "title": "客户",
                    "orderable": false,
                    "data": "customerName",
                    "render": function (data, type, full, meta) {
                        return emptyStringConvert(full.customerName) + '<p>' + emptyStringConvert(full.customerPhone) + '</p>';
                    }
                },
                {
                    "title":"订单状态",
                    "orderable": false,
                    "data": "status",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "title":"当前完成节点",
                    "orderable": false,
                    "data": "latestEndNodeName",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "title":"最新备注时间",
                    "orderable": false,
                    "data": "lastRemarkTime",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "title":"业务类型",
                    "orderable": false,
                    "data": "businessProductName",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "title":"产品",
                    "orderable": false,
                    "data": "productName",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "title":"渠道",
                    "orderable": false,
                    "data": "channelName",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "title":"签单时间",
                    "orderable": false,
                    "data": "signTime",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "title":"签单商务",
                    "orderable": false,
                    "data": "signUserName",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "title":"签单商务",
                    "orderable": false,
                    "data": "signUserName",
                    "render": function (data, type, full, meta) {
                        return data+'<p>'+full.signUserOrgName+'</p>';
                    }
                },
                {
                    "title":"流程人员",
                    "orderable": false,
                    "data": "flowUserName",
                    "render": function (data, type, full, meta) {
                        return data ? data+'<p>'+emptyStringConvert(full.flowUserOrgName)+'</p>': '';
                    }
                },
                {
                    "title":"需求金额（元）",
                    "orderable": false,
                    "data": "money",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                }
            ],
            "columnDefs": [{
                targets: [3], //第1，2，3列
                createdCell: function (td, cellData, rowData, row, col) {
                    if (rowData.orderTimeStatus == '${TIME_OUT}') {
                        $(td).parent().addClass("bgRed");//订单超期
                        return;
                    } else if (rowData.nodeTimeStatus == '${TIME_OUT}') {//节点超期
                        $(td).parent().addClass("bgBlue");

                    } else if (rowData.receiveTimeStatus == '${TIME_OUT}' && rowData.status == '分配待接收') {//接收超期
                        $(td).parent().addClass("bgYellow");
                        return;
                    } else if (rowData.distributionTimeOutStatus == '${TIME_OUT}' && rowData.status == '下单待分配') {//分配超期
                        $(td).parent().addClass("bgGreen");//分配
                        return;
                    }

                }
            }]
        };
        table.render(opt);
    });

    //列表刷新
    function tableReload() {
        table.ajax.reload();
    }

</script>
</body>
</html>